package com.ruoyi.web.controller.qualifica;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.qualifica.domain.Qualifica;
import com.ruoyi.qualifica.service.IQualificaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资质信息Controller
 *
 * @author ruoyi
 * @date 2025-05-06
 */
@RestController
@RequestMapping("/qualifica/qualifica")
public class QualificaController extends BaseController
{
    @Autowired
    private IQualificaService qualificaService;

    /**
     * 查询资质信息列表
     */
    @PreAuthorize("@ss.hasPermi('qualifica:qualifica:list')")
    @GetMapping("/list")
    public TableDataInfo list(Qualifica qualifica)
    {
        startPage();
        List<Qualifica> list = qualificaService.selectQualificaList(qualifica);
        return getDataTable(list);
    }

    /**
     * 导出资质信息列表
     */
    @PreAuthorize("@ss.hasPermi('qualifica:qualifica:export')")
    @Log(title = "资质信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Qualifica qualifica)
    {
        List<Qualifica> list = qualificaService.selectQualificaList(qualifica);
        ExcelUtil<Qualifica> util = new ExcelUtil<Qualifica>(Qualifica.class);
        return util.exportExcel(list, "资质信息数据");
    }

    /**
     * 获取资质信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('qualifica:qualifica:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qualificaService.selectQualificaById(id));
    }

    /**
     * 新增资质信息
     */
    @PreAuthorize("@ss.hasPermi('qualifica:qualifica:add')")
    @Log(title = "资质信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Qualifica qualifica)
    {
        return toAjax(qualificaService.insertQualifica(qualifica));
    }

    /**
     * 修改资质信息
     */
    @PreAuthorize("@ss.hasPermi('qualifica:qualifica:edit')")
    @Log(title = "资质信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Qualifica qualifica)
    {
        qualifica.setUpdateType(DicConstants.BUSINESS_Manager.getCode());
        return toAjax(qualificaService.updateQualifica(qualifica));
    }

    /**
     * 删除资质信息
     */
    @PreAuthorize("@ss.hasPermi('qualifica:qualifica:remove')")
    @Log(title = "资质信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qualificaService.logicDeleteQualifica(ids,DicConstants.BUSINESS_Manager.getCode(),SecurityUtils.getUserId()));
    }
}
